﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace HotelManageSystem.Models
{
    /// <summary>
    /// Class Name:     ProbationModel
    /// Author:         Wangzx
    /// Creation Date:  2011-12-29
    /// Description:    所有试用期员工的视图模型,用于转正管理的模型
    /// QA:             
    /// -----------------------------------------
    /// </summary>
    public class ProbationModel
    {
        [Display(Name = "员工编号")]
        public int ID { get; set; }

        [Display(Name = "员工姓名")]
        public string Name { get; set; }

        [Display(Name = "性别")]
        [StringLength(1, ErrorMessage = "性别不能超过1个字符")]
        public string Sex { get; set; }

        [Display(Name = "部门")]
        public string Department { get; set; }

        [Display(Name = "职位")]
        public string Post { get; set; }

        [Display(Name = "入职时间")]
        [DataType(DataType.Date)]
        public DateTime JoinTime { get; set; }

        [Display(Name = "试用期天数")]
        public int ProbationDates { get; set; }

        [Display(Name = "延长天数")]
        [RegularExpression(@"^[0-9]*$", ErrorMessage = "必须输正整数")]
        public int ExtendDates { get; set; }

        //转正结果
        public string ProbationResult { get; set; }
        /**********************************************************/
        [Display(Name = "转正日期")]
        [DataType(DataType.Date)]
        public DateTime PassProbationDate
        {
            get { return JoinTime.AddDays(ProbationDates); }
        }

        [Display(Name = "剩余转正天数")]
        public string DaysRemaining
        {
            get
            {
                int days = ((TimeSpan)(DateTime.Now - JoinTime)).Days;
                int daysRemaing = ProbationDates - days;
                return daysRemaing >= 0 ? daysRemaing.ToString() : "已过";
            }
        }

    }
}